//
// Created by caedmon on 2017/12/12 0012.
//

#include <stdio.h>
#define SIZE 5
void fun1(const double src[], double dst[], int n);
void fun2(const double * src, double * dst, int n);
void fun3(const double * src, double * dst, const double * end);
//数组表示法的函数
void fun1(const double src[], double dst[], int n){
    int i ;
    for(i = 0; i < n; i++){
        dst[i] = src[i];
    }
}
//指针表示法
void fun2(const double * src, double * dst, int n){
    int i = 0;
    for(i ; i < n; i++){
        *(dst + i) = *(src + i);
    }
}
//指针递增表示法
void fun3(const double * src, double * dst, const double * end){
    while(src < end){
        *dst = *src;
        src++;
        dst++;
    }
}

void practise_10_2(void){
    const double source[SIZE] = {1.1, 2.2, 3.3, 4.4, 5.5};
    double target1[SIZE], target2[SIZE], target3[SIZE];
    int i;
    fun1(source,target1,SIZE);
    for(i = 0; i < SIZE; i++){
        printf("%.1lf ", target1[i]);
    }
    putchar('\n');
    fun2(source,target2,SIZE);
    for (i = 0; i < SIZE; i++) {
        printf("%.1lf ", target2[i]);
    }
    putchar('\n');
    //第三个参数有变化
    fun3(source,target3,source + SIZE);
    for (i = 0; i < SIZE; i++) {
        printf("%.1lf ", target3[i]);
    }
    putchar('\n');
}